﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HammerMUD.System;
using HammerMUD.Characters;
using HammerMUD.Accounts;

namespace HammerMUD.Commands
{
    class QuitCommand : Command
    {
        public QuitCommand()
        {
            Name = "quit";
            Help = "quit";
            SecurityLevel = HammerMUD.Admin.SecurityLevel.User;
        }

        public override void Do(User from, List<string> arguments)
        {
            from.CurrentState.Base = BaseState.AccountMenu;
            from.CurrentState.AccountMenu = AccountMenuState.Menu;

            from.Send("Quitting to account menu..");

            foreach (Character c in from.UserAccount.CurrentCharacter.CurrentRoom.Characters)
            {
                if (c.Equals(from.UserAccount.CurrentCharacter))
                {
                    continue;
                }

                c.Send(from.UserAccount.CurrentCharacter.Name + " has quit");
            }

            from.Send(AccountMenuUtilities.AccountMenu);
            from.UserAccount.CurrentCharacter.CurrentRoom.Characters.Remove(from.UserAccount.CurrentCharacter);
            from.UserAccount.CurrentCharacter = null;
        }
    }
}
